按了顶上的删除(多项删除)
单列复选框删除 js语句
1 删除
1
多列复选框删除js语句
先在table外套个form表单 并且指定id,其中给复选框指定name 和 value
<td><input type="checkbox" name="ids" value="${customer.id}"/></td>
1
1
参考
1 <%@ page language="java" contentType="text/html; charset=utf-8" 2 pageEncoding="utf-8"%> 3 <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 <%@taglib uri="http://www.WFReduceContent.com" prefix="reduce"%> 5 6 7 8 985 86 87Insert title here 10 11 12
1 package cn.itcast.Controller; 2 3 import java.io.IOException; 4 import javax.servlet.ServletException; 5 import javax.servlet.annotation.WebServlet; 6 import javax.servlet.http.HttpServlet; 7 import javax.servlet.http.HttpServletRequest; 8 import javax.servlet.http.HttpServletResponse; 9 10 import cn.itcast.service.CustomerService;11 import cn.itcast.service.impl.CustomerServiceImpl;12 13 public class DelCustomerServlet extends HttpServlet {14 private static final long serialVersionUID = 1L;15 private CustomerService service= new CustomerServiceImpl();16 public DelCustomerServlet() {17 super();18 }19 20 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {21 String method=request.getParameter("method");22 if("delMultiple".equals(method)) //多重删除23 {24 String ids[]=request.getParameterValues("ids");25 if(null!=ids&&ids.length>0)26 for(String id:ids)27 service.delCustomerById(id);28 request.getRequestDispatcher("ShowAllCustomer").forward(request, response);29 return;30 }31 //单条删除32 String customerId=request.getParameter("customerId");33 System.out.println( "servlet"+customerId);34 service.delCustomerById(customerId.trim());35 request.getRequestDispatcher("ShowAllCustomer").forward(request, response);36 }37 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {38 this.doGet(request, response);39 }40 41 }